FROM golang:1.19.1-alpine3.15 AS builder
COPY . /go/src/gitlab.com/jakinss321/chat

WORKDIR /go/src/gitlab.com/jakinss321/chat
# Create slimest possible image
RUN go build --mod=vendor -ldflags="-w -s" -o /go/bin/server /go/src/gitlab.com/jakinss321/chat/cmd

FROM alpine:3.15
# Copy binary from builder
COPY --from=builder /go/bin/server /go/bin/server
COPY ./public /app/public

WORKDIR /app
# Set entrypoint
ENTRYPOINT ["/go/bin/server"]